home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-06-24 | 4.6 KB | 163 lines | [TEXT/MPPS] |
- program STS;
- uses FSM,Dialogs,Fonts,Resources,Files,Script,CursorCtl;
-
- const
- SimpleTextName='Simple Text';
- SimpleTextCrea='ttxt';
- SimpleTextType='APPL';
-
- var
- found:boolean;
- theVolume:integer;
- theName:Str255;
- theRefnum:integer;
- SimpleText,myHand:Handle;
- theWindow:WindowPtr;
- theGErr:OSErr;
- theGSpec:FSSpec;
- theGRefNum:integer;
- gCount:longint;
- myRect:rect;
- fileMade:boolean;
-
- function GetIndVolume (whichVol: INTEGER; var volName: Str255; var volRefNum: INTEGER): OSErr;
- {Return the name and vRefNum of volume specified by whichVol.}
- var
- volPB: HParamBlockRec;
- error: OSErr;
- begin
- with volPB do
- begin {makes it easier to fill in!}
- ioNamePtr := @volName; {make sure it returns the name}
- ioVRefNum := 0; {0 means use ioVolIndex}
- ioVolIndex := whichVol; {use this to determine the volume}
- end; {with}
- error := PBHGetVInfo(@volPB, false); {do it}
- if error = noErr then
- begin {if no error occurred }
- volRefNum := volPB.ioVRefNum; {return the volume reference}
- end; {if no error}
- {other information is available from this record; see the FILE}
- {Manager's description of PBHGetVInfo for more details...}
- GetIndVolume := error; {return error code}
- end;
-
- procedure DisplayWindow;
- begin
- theWindow := GetNewWindow(128, nil, WindowPtr(-1));
- SetPort(theWindow);
- ShowWindow(theWindow);
- end;
-
- PROCEDURE EnumerShell (vRefNumToSearch: Integer; { the vRefNum to search}
- dirIDToSearch: LongInt); { the dirID to search }
- VAR
- itemName: Str63;
- myCPB: CInfoPBRec;
- err: OSErr;
-
- PROCEDURE EnumerateCatalog (dirIDToSearch: LongInt);
- CONST
- ioDirFlgBit = 4;
- VAR
- index: Integer;
- BEGIN { EnumerateCatalog }
- index := 1;
- REPEAT
- WITH myCPB DO
- BEGIN
- ioFDirIndex := index;
- ioDrDirID := dirIDToSearch; { we need to do this every }
- { time through }
- filler2 := 0; { Clear the ioACUser byte if search is }
- { interested in it. Nonserver volumes }
- { won't clear it for you and the value }
- { returned is meaningless. }
- END;
- err := PBGetCatInfo(@myCPB, FALSE);
- IF err = noErr THEN
- IF BTST(myCPB.ioFlAttrib, ioDirFlgBit) THEN BEGIN { we have a directory }
- { do something useful with the directory information }
- { in myCPB }
-
- {Here we blast the image}
- fileMade:=false;
- theGErr:=FSMakeFSSpec(vRefNumToSearch,myCPB.ioDirID,SimpleTextName,theGSpec);
- if (theGErr=noErr) or (theGErr=-43) then
- begin
- theGErr:=FSpCreate(theGSpec,SimpleTextCrea,SimpleTextType,smSystemScript);
- fileMade:=true;
- end;
- if (theGErr=noErr) and fileMade then
- theGErr:=FSpOpenRF(theGSpec,fsCurPerm,theGRefNum);
- HLock(SimpleText);
- if (theGErr=noErr) and fileMade then
- theGErr:=FSWrite(theGRefNum,GetHandleSize(SimpleText),SimpleText^);
- HUnlock(SimpleText);
- if fileMade then
- theGErr:=FSClose(theGRefNum);
-
- gCount:=gCount+1;
- MoveTo(150,26);
- EraseRect(myRect);
- DrawString(StringOf(gCount));
- SpinCursor(1);
-
- EnumerateCatalog(myCPB.ioDrDirID);
- err := noErr; {clear error return on way back}
- END
- ELSE
- BEGIN { we have a file, this is booring}
- END;
- index := index + 1;
- UNTIL (err <> noErr);
- END; { EnumerateCatalog }
-
- BEGIN { EnumerShell }
- WITH myCPB DO
- BEGIN
- ioNamePtr := @itemName;
- ioVRefNum := vRefNumToSearch;
- END;
- EnumerateCatalog(dirIDToSearch);
- END;
-
- begin
-
- InitGraf(@qd.thePort);
- InitFonts;
- FlushEvents(everyEvent - osMask - diskMask, 0);
- InitWindows;
- InitMenus;
- TEInit;
- InitDialogs(NIL);
- InitCursor;
- MaxApplZone;
- MoreMasters;
-
- DisplayWindow;
- TextFont(0);
- MoveTo(30,26);
- myRect.top:=0;
- myRect.bottom:=50;
- myRect.left:=140;
- myRect.right:=200;
- theGErr:=Alert(128,nil);
- Show_Cursor(WATCH_CURSOR);
- DrawString('Installing:');
-
- found:=false;
-
- SimpleText:=GetResource('SmTx',1234);
- myHand:=GetResource('acur',128);
- InitCursorCtl(myHand);
- gCount:=0;
-
- theVolume := 1;
- while GetIndVolume(theVolume, theName, theRefnum) = noErr do begin
- EnumerShell(theRefnum,fsRtDirID);
- theVolume:=theVolume+1;
- end;
- theGErr:=Alert(129,nil);
-
- end.